﻿Public Class WebForm1
    Inherits System.Web.UI.Page
    Private dat As String = Date.Now.ToShortDateString

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If addpagewasloaded = False Then
            Me.Datum.Text = dat
            addpagewasloaded = True
        End If


    End Sub

    Private Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged

    End Sub

    Private Sub Save_Click(sender As Object, e As EventArgs) Handles Save.Click
        AddToXmlFile(Me.Datum.Text, Me.StVo.Text, Me.Pg.Text, Me.DropDownList1.SelectedValue, Me.Rayon.Text)
        RefreshList()
    End Sub

    Protected Sub Edit_Click(sender As Object, e As EventArgs)
        Me.Datum.Enabled = True

        RemoveFromXML(Me.Datum.Text)
        AddToXmlFile(Me.Datum.Text, Me.StVo.Text, Me.Pg.Text, Me.DropDownList1.SelectedValue, Me.Rayon.Text)
    End Sub

    Protected Sub Loadit_Click(sender As Object, e As EventArgs)
        Dim mandat = (From a In listofmandate
                    Where a.Datum = Me.Datum.Text
                    Select a).FirstOrDefault

        If mandat IsNot Nothing Then
            With mandat
                Me.Datum.Text = mandat.Datum
                Me.Rayon.Text = mandat.Rayon
                Me.StVo.Text = .StvoAnzahl
                Me.Pg.Text = .PgAnzahl
                Me.DropDownList1.SelectedValue = .Type.ToString
            End With
        End If
        Me.Datum.Enabled = False
    End Sub
End Class